/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package bpmn.impl;

import bpmn.BpmnPackage;
import bpmn.TimeDateExpression;
import bpmn.Timer;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Timer</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link bpmn.impl.TimerImpl#getTimeDate <em>Time Date</em>}</li>
 *   <li>{@link bpmn.impl.TimerImpl#getTimeCycle <em>Time Cycle</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class TimerImpl extends EventDetailImpl implements Timer {
	/**
	 * The cached value of the '{@link #getTimeDate() <em>Time Date</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTimeDate()
	 * @generated
	 * @ordered
	 */
	protected TimeDateExpression timeDate;

	/**
	 * The cached value of the '{@link #getTimeCycle() <em>Time Cycle</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTimeCycle()
	 * @generated
	 * @ordered
	 */
	protected TimeDateExpression timeCycle;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected TimerImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return BpmnPackage.Literals.TIMER;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TimeDateExpression getTimeDate() {
		if (timeDate != null && timeDate.eIsProxy()) {
			InternalEObject oldTimeDate = (InternalEObject)timeDate;
			timeDate = (TimeDateExpression)eResolveProxy(oldTimeDate);
			if (timeDate != oldTimeDate) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, BpmnPackage.TIMER__TIME_DATE, oldTimeDate, timeDate));
			}
		}
		return timeDate;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TimeDateExpression basicGetTimeDate() {
		return timeDate;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTimeDate(TimeDateExpression newTimeDate) {
		TimeDateExpression oldTimeDate = timeDate;
		timeDate = newTimeDate;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.TIMER__TIME_DATE, oldTimeDate, timeDate));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TimeDateExpression getTimeCycle() {
		if (timeCycle != null && timeCycle.eIsProxy()) {
			InternalEObject oldTimeCycle = (InternalEObject)timeCycle;
			timeCycle = (TimeDateExpression)eResolveProxy(oldTimeCycle);
			if (timeCycle != oldTimeCycle) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, BpmnPackage.TIMER__TIME_CYCLE, oldTimeCycle, timeCycle));
			}
		}
		return timeCycle;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TimeDateExpression basicGetTimeCycle() {
		return timeCycle;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTimeCycle(TimeDateExpression newTimeCycle) {
		TimeDateExpression oldTimeCycle = timeCycle;
		timeCycle = newTimeCycle;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.TIMER__TIME_CYCLE, oldTimeCycle, timeCycle));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case BpmnPackage.TIMER__TIME_DATE:
				if (resolve) return getTimeDate();
				return basicGetTimeDate();
			case BpmnPackage.TIMER__TIME_CYCLE:
				if (resolve) return getTimeCycle();
				return basicGetTimeCycle();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case BpmnPackage.TIMER__TIME_DATE:
				setTimeDate((TimeDateExpression)newValue);
				return;
			case BpmnPackage.TIMER__TIME_CYCLE:
				setTimeCycle((TimeDateExpression)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case BpmnPackage.TIMER__TIME_DATE:
				setTimeDate((TimeDateExpression)null);
				return;
			case BpmnPackage.TIMER__TIME_CYCLE:
				setTimeCycle((TimeDateExpression)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case BpmnPackage.TIMER__TIME_DATE:
				return timeDate != null;
			case BpmnPackage.TIMER__TIME_CYCLE:
				return timeCycle != null;
		}
		return super.eIsSet(featureID);
	}

} //TimerImpl
